Figures for the SBI2 poster¶

  • Plates 50, 46, 47, 48 and 49 are compared here. Only the final time points of plate 48 and plate 49 are taken for analysis.
  • Normalization: Negcon normalization
  • Mean average precision (mAP) values are calculated as difference to controls
In [ ]:
### Modules import
import plotly.express as px
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly.io as pio
import pandas as pd
from pathlib import Path

Reading the dataframes¶

In [ ]:
combined_moa_50_46_47_df = pd.read_csv('copairs_csv\\PrecisionValues_with_MoA_allplates_Negcon_wrt_Controls.csv')
combined_moa_48_49_df = pd.read_csv('copairs_csv\\PrecisionValues_with_MoA_allplates_Negcon_wrt_Controls_48and49.csv')
In [ ]:
#Reading the cellcount df
copairs_dir = Path("copairs_csv")

combined_moa_cellcount_df = pd.read_csv(
    copairs_dir / "PrecisionValues_with_MoA_Negcon_wrt_Control_allplates_cellcount.csv"
)

Mean average precision values of all compounds¶

In [ ]:
combined_box_plot = go.Figure()

combined_box_plot.add_trace(go.Box(y=combined_moa_50_46_47_df['average_precision_std'], name = 'Standard Cellpainting dyes', boxpoints='all', hovertext=combined_moa_50_46_47_df['MoA']+'-'+ combined_moa_50_46_47_df['Common Name']))
combined_box_plot.add_trace(go.Box(y=combined_moa_50_46_47_df['average_precision_act'], name = 'Phalloidin 400LS', boxpoints='all', hovertext=combined_moa_50_46_47_df['MoA']+'-'+ combined_moa_50_46_47_df['Common Name']))
combined_box_plot.add_trace(go.Box(y=combined_moa_50_46_47_df['average_precision_mito'], name = 'Tocris MitoBrilliant', boxpoints='all', hovertext=combined_moa_50_46_47_df['MoA']+'-'+ combined_moa_50_46_47_df['Common Name']))
combined_box_plot.add_trace(go.Box(y=combined_moa_48_49_df['mean_average_precision_batch3'], name = 'Saguaro + <br> Standard CellPainting dyes', boxpoints='all', hovertext=combined_moa_48_49_df['MoA']+'-'+ combined_moa_48_49_df['Common Name']))
combined_box_plot.add_trace(go.Box(y=combined_moa_48_49_df['mean_average_precision_batch5'], name = 'Saguaro dyes', boxpoints='all', hovertext=combined_moa_48_49_df['MoA']+'-'+ combined_moa_48_49_df['Common Name']))

combined_box_plot.update_layout(height=2000,width=3000, font_family='Arial', font=dict(size=40, color='Black'), boxmode='group',yaxis_title = 'Mean average precision')
combined_box_plot.show('notebook')

Comparison of Mean average precision¶

  • Comparison between standard CP and Saguaro
  • Comparison between standard CP and Saguaro+CP
Standard cellpainting vs Saguaro¶
In [ ]:
saguaro_fig = px.scatter(x =combined_moa_50_46_47_df['average_precision_std'], y=combined_moa_48_49_df['mean_average_precision_batch5'],labels={'x':'Mean Average Precision - Standard CellPainting dyes', 'y':'Mean Average Preicison - <br> Saguaro dyes'}, color=combined_moa_50_46_47_df['MoA'])
saguaro_fig.update_layout(legend=dict(orientation="h"), height=1800, width=2000, font_family='Arial', font=dict(size=28, color='Black'))
saguaro_fig.update_traces(marker=dict(size=20))
saguaro_fig.show('notebook')
Standard cellpainting vs Saguaro+CP¶
In [ ]:
saguaro_CP_fig = px.scatter(x =combined_moa_50_46_47_df['average_precision_std'], y=combined_moa_48_49_df['mean_average_precision_batch3'],labels={'x':'Mean Average Precision - Standard CellPainting dyes', 'y':'Mean Average Preicison - <br> Saguaro dyes followed by CellPainting dyes'}, color=combined_moa_50_46_47_df['MoA'])
saguaro_CP_fig.update_layout(legend=dict(orientation="h"), height=1800, width=2000, font_family='Arial', font=dict(size=28, color='Black'))
saguaro_CP_fig.update_traces(marker=dict(size=20))
saguaro_CP_fig.show('notebook')
Saguaro vs Saguaro+CP¶
In [ ]:
saguaro_saguaro_CP_fig = px.scatter(x = combined_moa_48_49_df['mean_average_precision_batch3'],y = combined_moa_48_49_df['mean_average_precision_batch5'], labels={'x':'Mean Average Preicison - Saguaro dyes followed by CellPainting dyes', 'y':'Mean Average Preicison - Saguaro dyes'}, color=combined_moa_50_46_47_df['MoA'])
saguaro_saguaro_CP_fig.update_layout(legend=dict(orientation="h"), height=800, width=1000)
saguaro_saguaro_CP_fig.show('notebook')

Mean average precision values - MoA¶

The size of the markers represent the average number of cells present in the replicates. The number of cells were normalized by dividing the actual number by 100 for easier plotting.

In [ ]:
map_cc_name = (
    (
        "average_precision_std",
        "Metadata_Count_Cells_Std_norm",
        "Standard CellPainting dyes",
    ),
    ("average_precision_act", "Metadata_Count_Cells_act_norm", "Phalloidin 400LS"),
    ("average_precision_mito", "Metadata_Count_Cells_Saguaro_norm", "MitoBrilliant"),
    (
        "mean_average_precision_batch3",
        "Metadata_Count_Cells_CellPainting_norm",
        "Saguaro + Standard CellPainting dyes",
    ),
    ("mean_average_precision_batch5", "Metadata_Count_Cells_Saguaro_norm", "Saguaro"),
)
In [ ]:
scatter_plot = go.Figure()
for map_field, cc_field, name in map_cc_name:
    scatter_plot.add_trace(
        go.Scatter(
            x=combined_moa_cellcount_df["MoA"],
            y=combined_moa_cellcount_df[map_field],
            # hovertext=[combined_moa_cellcount_df[map_field]],
            hovertext=[combined_moa_cellcount_df["MoA"]],
            mode="markers",
            name=name,
            marker_size=combined_moa_cellcount_df[cc_field],
        )
    )

scatter_plot.update_layout(
    height=1800,
    width=2200,
    font_family="arial",
    font=dict(size=26, color="black"),
    boxmode="group",
    yaxis_title="mean average precision",
    legend=dict(yanchor="bottom", y=0.01, xanchor="right", x=0.99),
)
scatter_plot.update_xaxes(tickangle=90, categoryorder="total ascending")
scatter_plot.show('notebook')

Difference in mean average precision values¶

In [ ]:
# Generating columns for difference in mAP for std CP, Saguaro and Saguaro+CP
combined_std_Saguaro_SaguaroCP_df_1 = combined_moa_50_46_47_df[['average_precision_std', 'Common Name', 'MoA', 'BRD ID']]
combined_std_Saguaro_SaguaroCP_df_2 = combined_moa_48_49_df [['mean_average_precision_batch3', 'mean_average_precision_batch5', 'Common Name', 'MoA', 'BRD ID']]
combined_std_Saguaro_SaguaroCP_df = pd.merge(combined_std_Saguaro_SaguaroCP_df_1, combined_std_Saguaro_SaguaroCP_df_2, on='BRD ID')


combined_std_Saguaro_SaguaroCP_df['std_vs_saguaro+CP'] = combined_std_Saguaro_SaguaroCP_df['average_precision_std'] - combined_std_Saguaro_SaguaroCP_df['mean_average_precision_batch3']
combined_std_Saguaro_SaguaroCP_df['std_vs_saguaro'] = combined_std_Saguaro_SaguaroCP_df['average_precision_std'] - combined_std_Saguaro_SaguaroCP_df['mean_average_precision_batch5']

Standard CellPainting dyes vs Saguaro dyes¶

The negative values indicate the better performance of Saguaro dyes

In [ ]:
fig = go.Figure()
fig.add_trace(go.Scatter(x=combined_std_Saguaro_SaguaroCP_df['MoA_x'], y=combined_std_Saguaro_SaguaroCP_df['std_vs_saguaro'],mode='markers', hovertext=combined_std_Saguaro_SaguaroCP_df['Common Name_x']))
fig.update_layout(height=1800,width=2000, font_family='Arial', font=dict(size=24, color='Black'))
fig.update_yaxes(title='Difference in <br> Mean average precision')
fig.update_xaxes(categoryorder='total ascending')
fig.update_traces(marker=dict(size=20))
fig.show('notebook')

Standard CellPainting dyes vs Saguaro+CP¶

The negative values indicate the better performance of Saguaro+CP

In [ ]:
fig = go.Figure()
fig.add_trace(go.Scatter(x=combined_std_Saguaro_SaguaroCP_df['MoA_x'], y=combined_std_Saguaro_SaguaroCP_df['std_vs_saguaro+CP'],mode='markers', hovertext=combined_std_Saguaro_SaguaroCP_df['Common Name_x']))
fig.update_layout(height=1800,width=2000, font_family='Arial', font=dict(size=24, color='Black'))
fig.update_yaxes(title='Difference in <br> Mean average precision')
fig.update_xaxes(categoryorder='total ascending')
fig.update_traces(marker=dict(size=20))
fig.show('notebook')